#include "linavg.h"



void linavg(const double * x, const double * f, long M, double * k, double * b){
	double beta  = 0;
	double alpha = 0;
	double gamma = 0;
	double delta = 0;
	long ksi;
	for(ksi = 0; ksi < M; ksi += 1){
		beta	+=	x[ksi];
		alpha	+=	x[ksi]*x[ksi];
		gamma	+=	f[ksi];
		delta	+=	f[ksi]*x[ksi];
	}
	double Delta = beta * beta - alpha * M;
	* k = (gamma * beta - M * delta) / Delta;
	* b = (beta * delta - alpha * gamma) / Delta;
}
